<template>
    <div class="box-wrapper">
        <div class="search-wrap">
            <div class="item">
                <el-input v-model="operateUserName" placeholder="操作用户"></el-input>
            </div>
            <div class="item">
                <el-input v-model="logTitle" placeholder="关键词"></el-input>
            </div>
            <div class="item">
                <el-select v-model="operateType" placeholder="操作类型">
                    <el-option label="新增" value="insert"></el-option>
                    <el-option label="更新" value="update"></el-option>
                    <el-option label="删除" value="delete"></el-option>
                </el-select>
            </div>
            <div class="item">
                <el-date-picker value-format="yyyy-MM-dd" v-model="startDate" type="date" placeholder="开始日期">
                </el-date-picker>
            </div>
            <div class="item">
                <el-date-picker value-format="yyyy-MM-dd" v-model="endDate" type="date" placeholder="结束日期">
                </el-date-picker>
            </div>
            <div class="item"></div>
            <div class="item"></div>
            <div class="item t-rig">
                <el-button class="btn bg-blue" @click="queryClick">查询</el-button>
                <el-button class="btn" @click="resetClick">重置</el-button>
            </div>
        </div>
        <el-table v-loading="loading" ref="multipleTable" :header-cell-style="headerStyle" :data="tableData" tooltip-effect="dark" style="width: 100%">
            <el-table-column prop="logTitle" label="关键词">
            </el-table-column>
            <el-table-column prop="operateUserName" label="操作用户">
            </el-table-column>
            <el-table-column prop="logdesc" label="日志描述">
            </el-table-column>
            <el-table-column prop="operateTime" label="时间">
            </el-table-column>
            <el-table-column prop="operateType" label="操作状态">
                <template slot-scope="scope">
                    <span v-if="scope.row.operateType == 'insert'">新增</span>
                    <span v-if="scope.row.operateType == 'update'">修改</span>
                    <span v-if="scope.row.operateType == 'delete'">删除</span>
                </template>
            </el-table-column>
            <!-- <el-table-column prop="oprate" label="操作">
                <template slot-scope="scope">
                    <el-button @click="handleClick(scope.row,'modify')" type="text" size="small">修改</el-button>
                    <el-button @click="handleClick(scope.row,'detail')" type="text" size="small">查看</el-button>
                    <el-button @click="roleClick(scope.row)" type="text" size="small">角色权限分配</el-button>
                </template>
            </el-table-column> -->
        </el-table>
        <div class="page" v-if="total > 0 && tableData.length > 0">
            <el-pagination
                background
                @size-change="handleSizeChange"
                @current-change="handleCurrentChange"
                :current-page.sync="currentPage"
                :page-sizes="[10,20,30,40]"
                :page-size="pageSize"
                layout="prev,pager,next,sizes,total"
                :total="total">
            </el-pagination>
        </div>
    </div>
</template>
<script>
import {request} from "../assets/js/utils/request";
export default{
    data() {
        return {
            loading: false,
            tableData: [],
            isDialog: false,
            headerStyle: {
                background: '#f2f2f2',
                color: '#000',
                // textAlign: 'center'
            },
            dataType: '',
            dataInfo: {},
            dataTitle: '',
            currentPage: 1,
            pageSize: 10,
            total: 0,
            operateUserName: '',
            operateType: '',
            logTitle: '',
            startDate: '',
            endDate: ''
        }
    },
    created() {
        this.initData()
    },
    methods: {
        roleClick(params) {
            console.log(params,'paaaa')
            // this.$router.push({
            //     url: '/roleAllocation',
            //     params: {
            //         roleId: params.roleId
            //     }
            // })
        },
        handleClick(params,type) {
            // console.log(params,type)
            this.isDialog = true
            if(type == 'modify') {
                this.dataTitle = '角色修改'
            }
            if(type == 'detail') {
                this.dataTitle = '角色详情'
            }
            this.dataType = type
            this.dataInfo = params
        },
        dialogChange() {
            this.isDialog = false
            this.initData()
        },
        addClick() {
            this.dataTitle = '新增角色'
            this.isDialog = true
        },
        queryClick() {
            this.initData()
        },
        resetClick() {
            this.operateUserName = ''
            this.operateType = ''
            this.logTitle = ''
            this.startDate = ''
            this.endDate = ''
            this.initData()
        },
        handleSizeChange(val) {
            this.pageSize = val
            this.currentPage = 1
            this.initData()
        },
        handleCurrentChange(val) {
            this.currentPage = val
            this.initData()
        },
        initData() {
            request({
                url: '/manager/log/logInfoQuery.jsp',
                method: 'post',
                data: {
                    txtAction: 'query',
                    operateUserName: this.operateUserName,
                    operateType: this.operateType,
                    logTitle: this.logTitle,
                    startDate: this.startDate,
                    endDate: this.endDate,
                    page: this.currentPage,
                    limit: this.pageSize
                }
            }).then(res => {
                if(res.code == 200) {
                    this.tableData = res.data || []
                    this.total = res.count
                    this.loading = false
                    if (this.tableData.length === 1) {
                        this.currentPage--
                        if (this.currentPage <= 0) {
                            this.currentPage = 1
                        }
                    }
                }
            })
        }
    }
}
</script>
<style lang="less" scoped>
.box-wrapper{
    background: #fff;
    .title-name{
        line-height: 30px;
        border-bottom: 1px solid #ddd;
        margin-bottom: 10px;
        span{
            color: #409EFF;
            display: inline-block;
            border-bottom: 2px solid #409EFF;
        }
    }
}
/deep/.search-wrap{
    margin: 20px 0;
    padding: 10px;
    display: flex;
    flex-wrap: wrap;
    background: #b1cbff;
    .item{
        width: 25%;
        padding: 5px;
        .btn{
            padding: 0;
            width: 80px;
            height: 32px;
            border: none;
            // background: #016aed;
        }
        .bg-blue{
            color: #ffffff;
            background: #016aed;
        }
        .el-select {
            width: 100%;
        }
        .el-input{
            .el-input__inner{
                height: 32px;
            }
        }
        .el-date-editor{
            width: 100%;
            .el-input{
                width: 100%;
            }
            .el-input__prefix{
                .el-input__icon{
                    line-height: 32px;
                }
            }
            .el-input__suffix{
                .el-input__suffix-inner{
                    .el-input-circle-close{
                        line-height: 32px;
                    }
                }
            }
        }
    }
}
.query-box{
    .btn{
        padding: 0;
        width: 100px;
        height: 32px;
        background: #016aed;
    }
}
.tabHeader{
    background: #f2f2f2;
}
.page{
    padding: 20px 0;
    border-top: 1px solid #d5d5d5;
    text-align: right;
}
</style>